Repository navigation
Fix review findings in the screened search - #190
Merged
Merged
Conversation
- aarch64: find screens only up to 64 bytes for 2- and 3-byte needles and up to 160 bytes for 4- to 15-byte needles, where NEON memmem won on the ubuntu-24.04-arm runner; other needles and targets keep 256 bytes - document the one-call-site rule on std_contains and std_rfind, and why str::find is the exception: a std_find wrapper moved core's shared Two-Way code to another codegen unit in default builds and made std_rfind on long haystacks 9 to 21% slower - correct the contains_str comment that blamed the gate failure on a second out-of-line arm - ShortSearch documents both scan directions - find_short and rfind_short share screen_block - crate docs, method docs, README, and CHANGELOG describe the paths for needles over 32 bytes and the aarch64 limit - run transform_search and search on the i686 job, where std has no SIMD contains, and unit-test the screened contains path with full blocks on every target Closes #189 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the seven findings from the review of #187 and #188 (#189).
Summary
find_screen_limit(needle)stopsfind's screen at 64 bytes for 2–3-byte needles and at 160 bytes for 4–15-byte needles, on aarch64 only. That is where theubuntu-24.04-armsweep from Use the screened short-needle search for find, contains, and rfind #188 showed NEONmemmemwinning: up to 1.26x slower with the screen for 2-byte needles from 64 bytes, and 1.13x for 8-byte needles at 192 bytes. Longer needles gained up to 256 bytes on aarch64 (0.14–0.40x), and every needle did on x86_64.rfindwon everywhere below 256 bytes on both, so it is unchangedstd_containsandstd_rfindnow states the rule the instruction-count gate depends on: each wrapper is the only call site of its std search with a&strpatterncontains_str's catch-all arm no longer blames the gate failure on a second out-of-line armstr::findstays a direct call in the two cold hand-offs, and the comment says why. Astd_findwrapper madestd_rfind9–21% slower on 512 B–4 KiB haystacks in a default 16-codegen-unit build, with no difference at one unit. Without the wrapper, 512 B and 1 KiBrfindmatchedmainexactlyShortSearchdocs (finding 4):FoundandTooManyFalseCandidatesnow describe both scan directionsfind_shortandrfind_shortsharescreen_block, an#[inline(always)]function that returns the 16-position hit maskcontains/finddocs, README, and CHANGELOG describe the paths for needles over 32 bytes,containson targets without SIMD, and the aarch64 limitlayout-32-bitjob also runstransform_searchandsearchfori686-pc-windows-msvc, where std has no SIMDcontainscontainspath with full blocks and the hand-off on every target. Making the hand-off returnfalsefails itMeasured impact
Same-binary A/B against
main, i7-11700K, default codegen units, two rounds. Every case is ×0.92–1.03:rfind, 512 B–4 KiB: ×0.99–1.03find, 32 B with an 8-byte needle: 10.5–10.7 → 9.8–10.0 nscontains, 40 B with a 32-byte needle: 9.0–9.1 → 8.3–8.4 nsSearch thresholdson aarch64 (ubuntu-24.04-arm). Each cell isfind'sCheetahStringtime against the faster ofstrandmemmemin the same run, geometric mean of four cases; lower is better. Columns: #175's rules, then #188, then this PR:The cells #188 made slower return to their pre-#188 level, and the 16-byte needles keep their gains. Over the whole sweep, against the faster backend:
findrfindcontainsThe x86_64
containschange is run-to-run noise: its code is unchanged on x86_64, and the instruction-count gate reports identical counts for every scenario.Verification
cargo fmt --check; clippy-D warningsfor all targets with all features, no default features, andserde,bytes,simdcargo test --all-features: 250 passed (2 new);--no-default-features --lib: 19 passedcargo +1.95.0 check --all-features; Python tests passlayout-32-bitjob:search5 passed,transform_search12 passedmainCloses #189
🤖 Generated with Claude Code